package com.trnnn.strutslit;

import java.io.PrintStream;
import java.text.SimpleDateFormat;
import java.util.Date;

public final class Debug {
	private Debug() {
	}

	private static boolean isOpen = false;
	private static PrintStream out = System.err;

	// private static PrintStream err=System.err;
	private static SimpleDateFormat sdf=new SimpleDateFormat("[yyyy/MM/dd HH:mm:ss] ");

	public static void registerOut(PrintStream out) {
		Debug.out = out;
	}

	public static void open() {
		isOpen = true;
	}

	public static void close() {
		isOpen = false;
	}

	public static PrintStream getOut() {
		return Debug.out;
	}

	public static void output(String str) {
		if (isOpen)
			Debug.out.println(sdf.format(new Date())+str);
	}

	public static void output(Object obj) {
		if (isOpen)
			Debug.out.println(sdf.format(new Date())+obj);
	}
}
